﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net;

namespace hondaab.portal.contacto_dir
{
    public partial class main_contacto : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

          int  idportal = 1;


            if (portales.exists(sf.entero(idportal)))
            {

                portales port = new portales();
                port = portales.getportales(idportal);
                lblcodigopostal.Text = port.codigopostal;
                lbldireccion.Text = port.direccion;
                lbllocalidad.Text = port.localidad;
                lblnombre1.Text = port.nombre;
                lbltelefno.Text = port.telefono;
                lbltexto.Text = port.textocontacto;
                lblprovincia.Text = provincias.getprovincias(port.idProvincias).nombre;
                Artem.Web.UI.Controls.GoogleMarker cg = new Artem.Web.UI.Controls.GoogleMarker();

                // el contenido del link...
                templateGoogleMap tg = new templateGoogleMap();
                tg.eventox = port;
                tg.idEventos = "1";

                cg.InfoWindowTemplate = tg;
                cg.Address = "Capitan cortes 12,Albacete,España";

                //cg.Latitude = sf.doble(tix.latitud);
                //cg.Longitude = sf.doble(tix.longitud);

                cg.IconUrl = "../../images/h.jpg";//torneo pasado
                Artem.Web.UI.Controls.GoogleSize gsize = new Artem.Web.UI.Controls.GoogleSize();
                gsize.Width = 30;
                gsize.Height = 25;

                cg.IconSize = gsize;
                GoogleMap2.Markers.Add(cg);

             //   GoogleMap2.Markers.Add(cg);


                //Artem.Web.UI.Controls.GoogleMarker cg = new Artem.Web.UI.Controls.GoogleMarker();


                //templateGoogleMap tg = new templateGoogleMap();
                //tg.port = port;
                //tg.idportal = port.idportal.ToString();

                //cg.InfoWindowTemplate = tg;
                //cg.Address = port.codigopostal + "," + port.direccion + "," + port.localidad + "," + provincias.getprovincias(port.idProvincias).nombre + ",España";



                //string csvValues = "";

                //string Respuesta_geo = "";
                //try
                //{
                //    WebRequest objWebRequest = WebRequest.Create("http://maps.google.com/maps/geo?q=" + cg.Address + "&output=csv");
                //    WebResponse objWebResponse = objWebRequest.GetResponse();
                //    Stream objWebStream = objWebResponse.GetResponseStream();

                //    using (StreamReader objStreamReader = new StreamReader(objWebStream))
                //    {
                //        csvValues = objStreamReader.ReadToEnd();
                //    }

                //    if (csvValues != null)
                //    {
                //        string[] geoValues = csvValues.Split(new char[] { ',' });
                //        if (geoValues.Length > 0)
                //        {
                //            Respuesta_geo = geoValues[0].ToString();
                //            //GoogleMap2.Latitude = sf.Doble(geoValues[2].ToString());
                //            //GoogleMap2.Longitude = sf.Doble(geoValues[3].ToString());
                //            //GoogleMap2.Zoom = 12;
                //        }
                //    }

                //}
                //catch (Exception exp)
                //{
                //    Response.Write(exp.Message);
                //}


                //              http://maps.google.com/maps/geo?q=luis badia 1 albacete

                //   GoogleMap2.Markers.Add(cg);


                if (port.email != "")
                {
                    hplemail.NavigateUrl = "mailto:" + port.email;
                    hplemail.Text = port.email;
                }
            }



        }


//        string constructuirGeoURLx(string direccion)
//        {
//            string ApiGoogle = "ABQIAAAAPA98ZhZ0FlZRZoqTfRQK1RTLWzYKVtXF8H0RNANNIf77A_d31BQtpsGcmw1z3BGr9TkYoWrsCILS_g";
//            string geoURL = "";

//            if (direccion != "")
//            {
//                direccion = direccion.Trim();
//                direccion = direccion.Replace(" ", "+");

//                geoURL = @"http://maps.google.com/maps/geo?
//                q=###ADDRESS###&output=###OUTPUT###&key=###KEY###";

//                //Sustitución de las variables
//                geoURL = geoURL.Replace("###ADDRESS###", direccion);
//                geoURL = geoURL.Replace("###OUTPUT###", "csv");
//                geoURL = geoURL.Replace("###KEY###", ApiGoogle);
//            }

//            return geoURL;
//        }
    }
}
